<template>
  <span>
    <el-empty :description="description"
              :image-size="imageSize"
              :image="image"
              :default="default"></el-empty>
    <buttonInput v-if="button"
                 v-bind="inheritProps(button)" />
  </span>
</template>

<script>
import buttonInput from '@/components/button/input'
export default {
  components: {
    buttonInput: buttonInput
  },
  data () {
    return {}
  },
  props: {
    description: {
      type: String,
      default: 'label-width'
    },
    imageSize: String,
    image: String,
    default: String,
    button: Object
  },
  created () {},
  methods: {
    // 继承转换属性
    inheritProps (template) {
      let cloneTemplate = {}
      Object.assign(cloneTemplate, template)

      let componentName = cloneTemplate.componentName

      switch (componentName.toKebabCase()) {
        case 'button-input':
          cloneTemplate.noText =
            Object.prototype.toString.call(cloneTemplate.noText) ==
            '[object Boolean]'
              ? cloneTemplate.noText
              : true
          delete cloneTemplate.visible
          break
      }

      delete cloneTemplate.componentName
      delete cloneTemplate.visible

      return cloneTemplate
    }
  }
}
</script>
